const { DataTypes } = require('sequelize')
const sequelize = require('../config/database')

const Captcha = sequelize.define('Captcha', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  phone: {
    type: DataTypes.STRING(20),
    allowNull: false
  },
  code: {
    type: DataTypes.STRING(10),
    allowNull: false
  },
  type: {
    type: DataTypes.STRING(20),
    allowNull: false // register, login, reset-password等
  },
  expiresAt: {
    type: DataTypes.DATE,
    allowNull: false
  }
}, {
  tableName: 'captchas',
  timestamps: true,
  createdAt: 'createdAt',
  updatedAt: false
})

export { Captcha}